<template>
  <div id="tabbar">
    <span @click="change(index)" v-for="(item, index) in tablist" :key="index" :class="{ active: tabIndex == index }">{{ item.text }}</span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tabIndex: 0,
      tablist: [{ text: "首页" }, { text: "订单" }, { text: "我的" }],
    };
  },
  methods: {
    change(index) {
      this.tabIndex = index;
    },
  },
};
</script>

<style scoped>
#tabbar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 15px 0;
  width: 100%;
  box-sizing: border-box;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
}
#tabbar span.active {
  color: rgb(43, 163, 237);
  font-weight: 700;
}
</style>